import Vue from 'vue'
import i18n from '@/language/index'
import Cookies from 'js-cookie'
import ElTableColumn from '@/components/el-table-column'
import ElTable from '@/components/el-table'
import viewImage from './components/viewImage'
import ScanQrCode from './components/scanQrCode'
import Skucontmoduler from '@/components/Skucontmoduler'
import Pay from '@/components/Pay'

import Element from 'element-ui'
import ElTabPaneExt from 'el-tab-pane-ext'
import './assets/styles/element-variables.scss'

import '@/assets/styles/index.scss' // global css
import '@/assets/styles/ruoyi.scss' // ruoyi css
import App from './App'
import store from './store'
import router from './router'
import directive from './directive' // directive
import plugins from './plugins' // plugins
import createQRCode from '@/utils/createQRCode'
import { download, upload } from '@/utils/request'
import calWidth from '@/utils/calWidth'
import calTableHeight from '@/utils/calTableHeight'
import thousand from '@/utils/thousand'
import num from '@/utils/num'
import setStatisticsDefautTime from '@/utils/setStatisticsDefautTime'
import useCopy from '@/utils/useCopy'
import { useDict } from '@/utils/useDict'
import randomColor from '@/utils/randomColor'
import { functionComponent } from '@/utils/functionComponent'
import { resetSortQuery, setSortQuery, setSortIconStyle, firstToUpper } from '@/utils/table/sort'
import {
  $tableRowClassName,
  $rowClick,
} from '@/utils/tableRow'
import { checkPermi } from '@/utils/permission'
import handleSum from '@/utils/handleSum'

import PageSearch from '@/components/PageSearch/index.vue'
import ProTable from '@/components/ProTable/index.vue'


import getSkuClassList from '@/utils/getSkuClassList'
import './assets/icons' // icon
import './permission' // permission control
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey, updateConfigByKey } from "@/api/system/config";
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree, } from "@/utils/ruoyi";
// 分页组件
import Pagination from "@/components/Pagination";
// 自定义表格工具组件
import RightToolbar from "@/components/RightToolbar"
// 富文本组件
import Editor from "@/components/Editor"
// 文件上传组件
import FileUpload from "@/components/FileUpload"
// 图片上传组件
import ImageUpload from "@/components/ImageUpload"
// 图片预览组件
import ImagePreview from "@/components/ImagePreview"
// 字典标签组件
import DictTag from '@/components/DictTag'
// 头部标签组件
import VueMeta from 'vue-meta'
// 字典数据组件
import DictData from '@/components/DictData'
// 图片懒加载
import VueLazyload from 'vue-lazyload'

/** 图片上传管理(S)*/
import ImgUploadManage from '@/components/imgUploadManage/index.vue'


// 全局方法挂载
Vue.prototype.$getSkuClassList = getSkuClassList
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.updateConfigByKey = updateConfigByKey
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.createQRCode = createQRCode
Vue.prototype.download = download
Vue.prototype.$upload = upload
Vue.prototype.handleTree = handleTree
Vue.prototype.calWidth = calWidth
Vue.prototype.calTableHeight = calTableHeight
Vue.prototype.functionComponent = functionComponent
Vue.prototype.setStatisticsDefautTime = setStatisticsDefautTime
Vue.prototype.useCopy = useCopy
Vue.prototype.useDict = useDict
Vue.prototype.$thousand = thousand
Vue.prototype.$randomColor = randomColor
Vue.prototype.handleSum = handleSum
Vue.prototype.$hasPermission = (str) => checkPermi([str])
Vue.prototype.isMobile = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)

Vue.prototype.$tableRowClassName = $tableRowClassName
Vue.prototype.$rowClick = $rowClick
Vue.prototype.$Bus = new Vue()
// Vue.prototype.$message  = Message
/************************** 表格排序相关 *******************************/
Vue.prototype.resetSortQuery = resetSortQuery
Vue.prototype.setSortQuery = setSortQuery
Vue.prototype.setSortIconStyle = setSortIconStyle
Vue.prototype.firstToUpper = firstToUpper
/************************** 表格排序相关end ****************************/

/************************** filter ****************************/
// 全局过滤器
Vue.filter('thousand', thousand)
Vue.filter('$num', num)
/************************** filter end ****************************/

// 全局组件挂载
Vue.component('DictTag', DictTag)
Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)
Vue.component('Editor', Editor)
Vue.component('FileUpload', FileUpload)
Vue.component('ImageUpload', ImageUpload)
Vue.component('ImagePreview', ImagePreview)
Vue.component('PageSearch', PageSearch)
Vue.component('ProTable', ProTable)
Vue.component('ImgUploadManage', ImgUploadManage)
Vue.component('Skucontmoduler', Skucontmoduler)
Vue.component('Pay', Pay)


Vue.use(directive)
Vue.use(VueLazyload)
Vue.use(plugins)
Vue.use(VueMeta)
Vue.use(ElTabPaneExt)
DictData.install()
Vue.use(viewImage)
Vue.use(ScanQrCode)

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */

// 修改 el-dialog 默认点击遮照为不关闭
Element.Dialog.props.closeOnClickModal.default = false
Element.TableColumn = {}
Element.Table = {}
Element.MessageBox.setDefaults({
  customClass: 'custom-message-box'
})
Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})
Vue.component('ElTableColumn', ElTableColumn)
Vue.component('ElTable', ElTable)


Vue.config.productionTip = false

export const app = new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})


